//
//  CAIViewController.m
//  CAIEmptyViewController
//
//  Created by 海参 on 06/10/2022.
//  Copyright (c) 2022 海参. All rights reserved.
//

#import "CAIViewController.h"
#import <CAIZEmptyViewKit/CAIZEmptyViewKit.h>

@interface CAIViewController ()<ZXEmptyViewControllerDelegate>

@property (nonatomic, strong) ZXEmptyViewController *emptyViewController;

@end

@implementation CAIViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    [self configEmptyView];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(emptyAction:)];
}

- (void)zxEmptyViewTouchAndActionWithController:(ZXEmptyViewController *)emptyView{
    [self emptyAction:nil];
}


- (void)emptyAction:(id)sender{
//    [self.emptyViewController addEmptyViewInController:self hasLocalData:NO emptyImage:[UIImage imageNamed:@"无人接单"] emptyTitle:@"没有搜到相关订单信息"];
//    self.emptyViewController.emptyErrorViewTouchEvent = YES;
//    [self.emptyViewController addEmptyErrorViewOnlyUpdateBtnInController:self hasLocalData:NO error:nil];
    [self.emptyViewController addEmptyErrorViewInController:self hasLocalData:NO error:[NSError errorWithDomain:@"" code:-1001 userInfo:nil]];
}

- (void)configEmptyView{
    EmptyCustomCenterButtonAppearance *appearance =[CAIEmptyViewGlobalConfig sharedInstance].customButtonAppearance;
//    appearance.actionBtnBackgroundColor = [UIColor caiColorWithHexString:@"#FF6A00"];
    appearance.actionBtnCornerRadius = 18;
    appearance.actionBtnSize = CGSizeMake(128, 36);
    appearance.actionBtnMarginTop = 16;
    appearance.actionBtnFont = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
    
    [CAIEmptyViewGlobalConfig sharedInstance].emptyErrorViewTouchEvent = NO;
    [CAIEmptyViewGlobalConfig sharedInstance].showEmptyErrorViewReloadButton = YES;
}

- (ZXEmptyViewController *)emptyViewController
{
    if (!_emptyViewController) {
        
        _emptyViewController = [[ZXEmptyViewController alloc] init];
        _emptyViewController.delegate = self;
    }
    return _emptyViewController;
}




- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
